package org.gw.building.repositories;

import org.gw.building.model.CourseContinueApply;
import org.gw.building.model.StuInfo;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

public interface CourseContinueApplyRepository extends JpaRepository<CourseContinueApply, String> {

	CourseContinueApply findFirstByStuInfo(StuInfo student);

	@Query("from CourseContinueApply t where (?1 is null or t.originTerm.id=?1) and (?2 is null or t.stuInfo.user.name like ?2 or t.stuInfo.user.uid like ?2)"
			+ " and (?3 is null or t.stuInfo.user.department=?3) and (?4 is null or t.originClassInfo.id=?4) and (?5 is null or t.stuInfo.sfwtzs =?5) and (?6 is null or t.status = ?6)")
	Page<CourseContinueApply> query(String term, String name, String department, String clazz, Integer isTzs,
                                    Integer status, Pageable pageable);
}
